<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function assign(obj, keyPath, value) {
        // debugger
        lastKeyIndex = keyPath.length - 1
        for (var i = 0; i < lastKeyIndex; i++) {
          key = keyPath[i]
          if (!(key in obj)) {
            obj[key] = {}
          }
          obj = obj[key]
        }
        obj[keyPath[lastKeyIndex]] = value
      }
      var settings = {}

      assign(settings, ['a', 'b', 'c'], '88888')
      
    </script>
  </body>
</html>
